﻿#ifndef MESSAGE_H
#define MESSAGE_H

#include <QObject>
#include "dingdan.h"
#include <QJsonObject>

class Message : public QObject
{
    Q_OBJECT
public:
    enum MessageType{
        SaleOut=0,          //销售单
        SaleBack=1,         //销退单
        PurchaseIn=2,       //采购单
        PurchaseBack=3,     //采退单
        PurchaseDingdan=4,  //采购订单
        TicketOut=5,        //开票
        MoneyIn=6,          //收款
        TicketIn=7,         //收票
        MoneyOut=8,         //付款
        TicketAdjust=9,     //票款调整
        ProductBatch=10,    //商品批导入
        TicketCount=11,     //发票盘点
        MoneyCount=12,      //资金盘点
        ProductCount=13,    //商品盘点
        SplitMoney=14,      //拆分差价
        FinanceIn=15,       //营外收入
        FinanceOut=16,      //营外支出
        TaxRateChange=17,   //税率变更
    };

    Q_ENUM(MessageType)

    explicit Message(QObject *parent = nullptr);

    int id;
    QString messageId;      //消息ID
    QString dingdanId;      //消息对应订单ID
    QString sourceUsername; //消息发送者用户名
    QString targetUsername; //消息接收者用户名
    int relationType;       //用户关系类型
    bool isSend;            //是否为发送的消息
    int type;               //消息类型
    double ticketIn;        //应收发票
    double ticketOut;       //应开发票
    double moneyIn;         //应收货款
    double moneyOut;        //应付货款
    QString date;           //消息生成日期
    QString opNickName;     //操作员
    QString remark;         //备注

    QString getMessageTypeStr();

    double getMoneyValue();

    void loadFromJsonObject(QJsonObject obj);

    UserRelation* getUserRelation();
signals:

public slots:

private:
    UserRelation *relation;
};

#endif // MESSAGE_H
